<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>layui</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet"
	th:href="@{/manager/layui/lib/layui-v2.5.5/css/layui.css}"
	href="/manager/layui/lib/layui-v2.5.5/css/layui.css" media="all">
<link rel="stylesheet" th:href="@{/manager/layui/css/public.css}"
	href="/manager/layui/css/public.css" media="all">
<style>
body {
	background-color: #ffffff;
}
</style>
</head>
<body>
	
	<div id="tree1" class="demo-tree demo-tree-box"></div>
	<!-- 	</form> -->
	<script th:src="@{/manager/layui/lib/layui-v2.5.5/layui.js}"
		src="/manager/layui/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
	<script>
		layui.use([ 'tree','util' ], function() {
			var tree = layui.tree ,util = layui.util , $ = layui.$;
		
			var parent$ = window.parent.layui.jquery;
			var index = parent.layer.getFrameIndex(window.name); 
			$.ajax({
				url:"/menu/treelist",
				type:"post",
				success: function(data){
					var result = JSON.stringify(data.data);
					console.info(result);
					tree.render({
						id:"treeid",
					    elem: '#tree1', //默认是点击节点可进行收缩
					    data: data.data,
					    click: function(obj){
// 					    	console.log(obj.data); //得到当前点击的节点数据
					    	var dat = obj.data;
					    	parent$('#parentId').val(dat.id);
					    	parent$('#parentvalue').val(dat.title);
					    	parent.layer.close(index);
					    }
					});
				},
				fail: function(){
					layer.msg("获取失败，请稍后重试");
				}
			});
			
			

		});
	</script>
</body>
</html>